package com.example.rbm;

import com.example.pojo.entity.PostDocument;
import org.springframework.data.elasticsearch.annotations.Highlight;
import org.springframework.data.elasticsearch.annotations.HighlightField;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

import java.util.List;

/**
 * @author 小岁
 * @version 2023/10/24 19:06
 */
public interface PostDocumentIndex extends ElasticsearchRepository<PostDocument,String> {
    List<PostDocument> findByPosName(String posName);

    //高亮显示
    @Highlight(fields = {
            @HighlightField(name = "posName")
    })
    @Query("{\"match\":{\"title\":\"?0\"}}")
    SearchHits<PostDocument> find(String keyword);
}
